package comxin.stream;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo1 {
    @Test
    public void method1(){
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("张三");
        list1.add("李三");
        list1.add("张无");
        Stream<String> stream = list1.stream();
        Collector<Object, ?, List<Object>> objectListCollector = Collectors.toList();
        List<Object> list = stream.filter(s -> s.startsWith("张")).collect(objectListCollector);
        System.out.println(list);
    }
}
